import {createStore} from 'vuex'
const store = createStore({
    state(){
        return {
            name: 'vuex缓存',
            sum:19,
            sumNum:0
        }
    },
    getters:{
        getSum(state){
            return state.sum;
        }
    },
    mutations:{
        add(state,num){
            state.sumNum = state.sum+num;
        },
        addActions(state,num){
             state.sum+num;
        }
    },
    actions:{
        addAsync(ctx,c){
            setTimeout(()=>{
              ctx.commit('addActions',c)
            },3000)
        }
    }
})
export default store;